package by.msokoloff.javaweb2015.datamodel;

import java.math.BigDecimal;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

@Entity
@Table(name = "extra")
public class Extra extends AbstractEntity {

	@Column
	private String name;

	@Column
	private String descr;

	@Column
	private BigDecimal price;

	@ManyToMany(targetEntity = TripOrder.class, fetch = FetchType.LAZY)
	@JoinTable(name = "extra_2_trip_order", joinColumns = { @JoinColumn(name = "extra_id", referencedColumnName = "id") }, inverseJoinColumns = { @JoinColumn(name = "trip_order_id", referencedColumnName = "id") })
	private Set<TripOrder> tripOrders;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescr() {
		return descr;
	}

	public void setDescr(String descr) {
		this.descr = descr;
	}

	public BigDecimal getPrice() {
		return price;
	}

	public void setPrice(BigDecimal price) {
		this.price = price;
	}

	public Set<TripOrder> getTripOrders() {
		return tripOrders;
	}

	public void setTripOrders(Set<TripOrder> tripOrders) {
		this.tripOrders = tripOrders;
	}

	@Override
	public String toString() {
		return "[Extra: " + this.name + "]";
	}

}
